package com.cn.service.shebao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.dao.shebao.SheBaoDao;
import com.cn.entity.TbSocialInsurance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @Author 社保管理的实现
 * @Date 2021/6/3 17:48
 * @Package com.cn.service.shebao
 * @Version 1.0
 */

@Service
public class SheBaoServiceImpl implements SheBaoService {

    @Autowired
    private SheBaoDao shebaoDao;

    /*
    社保信息分页处理
     */
    @Override
    public Page<TbSocialInsurance> allTbSocialInsurance(Long id,String idCard,String sbCard,Integer pageNum) {
        //分页查询条件
        QueryWrapper<TbSocialInsurance> wrapper = new QueryWrapper<>();
        if(id!=null){
            wrapper.like("id",id);
        }
        if(idCard!=null&&!"".equals(idCard)){
            wrapper.like("idCard",idCard);
        }
        if(sbCard!=null&&!"".equals(sbCard)){
            wrapper.like("sbCard",sbCard);
        }
        Page<TbSocialInsurance> page = new Page<>(pageNum,10);
        return shebaoDao.selectPage(page, wrapper);
    }

    /*
    添加社保人信息
     */
    @Override
    public int addShebao(TbSocialInsurance tbSocialInsurance) {
        return shebaoDao.insert(tbSocialInsurance);
    }

    /*
    删除社保人社保信息(逻辑删除)
     */
    @Override
    public int delShebao(Long id) {
        return shebaoDao.deleteById(id);
    }

    /*
    根据id查询社保人信息
     */
    @Override
    public TbSocialInsurance queryById(Long id) {
        TbSocialInsurance tbSocialInsurance = shebaoDao.selectById(id);
        return tbSocialInsurance;
    }

    /*
    更新社保人信息
     */
    @Override
    public int updateShebao(TbSocialInsurance tbSocialInsurance) {
        return shebaoDao.updateById(tbSocialInsurance);
    }

}
